<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/common/commonCss.jsp"/>
<jsp:include page="/common/commonJs.jsp"/>
<script language="javascript" src="${basePath }commonJs/tags/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
var resul = true;
var oldPassResult = true;
$(document).ready(function() {
	$("#updatePwd_class").addClass("content_hover");
	$("#updatePwdBtn").click(function() {
		resul = validateForm();
		if (resul){
			resul = false;
			$.messager.confirm('提示','确认要修改密码吗?', function(r) {
				if (r) {
					$.ajax({
						type : "post",
						url:'${basePath}system/user/updatePwd.shtml',
						data : {
							"loginPwd" : $("#loginPwd").val()
						},
						dataType : "json",
						async : false,
						success : function(result) {
							if (result == 1) {
								alertInfo("密码修改成功!");
								//清空表单
								$(':input','#updateForm')
								 .not(':button, :submit, :reset, :hidden')
								 .val('')
								 .removeAttr('checked')
								 .removeAttr('selected');
							} else {
								alertError("修改失败!");
							}
						},
						error : function(XMLHttpRequest) {
							ajaxError(XMLHttpRequest);
						}
					});
				}
			});
		}
	});
	$("#oldpassword").bind({
		blur : function() {
			var oldpassword = $("#oldpassword").val();
			$.ajax({
				type : "post",
				url:'${basePath}system/user/checkPwd.shtml',
				data : {
					"oldpassword" : oldpassword
				},
				dataType : "text",
				async : false,
				success : function(result) {
					if (result == "success") {
						oldPassResult = true;
						return true;
					} else {
						alertError("请输入正确的原密码!");
						oldPassResult = false;
						return false;
					}
				}
			});
		}
	});
});

function validateForm() {
	if(!oldPassResult){
		alertError("请输入正确的原密码!");
		return false;
	}
	var old = $("#oldpassword").val();
	var newDate = $("#loginPwd").val();
	var tooDate = $("#passwordtoo").val();
	if (old == "") {
		alertError("原始密码不能为空!");
		return false;
	}
	if (newDate == "") {
		alertError("现密码不能为空!");
		return false;
	}
	if (old == newDate) {
		alertError("现密码和原密码输入不能一致，请重新输入!");
		return false;
	}
	if (tooDate != newDate) {
		alertError("两次密码不一致!");
		return false;
	}
	return true;
}
</script>
<title>首页</title>
</head>
<body class="bg">

<div class="content m_auto">
		 <%@include file="../indexPage/index_tab.jsp"%>
    <div class="content_r mt10">
      <form action="${basePath }system/user/updatePwd.shtml" method="post" name="updateForm" id="updateForm">	
	<ul class="w360_c yonh_x_ul">
    	<li><label><span class="color_red ml5">*</span>原密码：</label><input type="password" name="oldpassword" id="oldpassword" class="iput_t w200" /></li>
        <li><label><span class="color_red ml5">*</span>现密码：</label><input type="password" name="loginPwd" id="loginPwd" class="iput_t w200" /></li>
        <li><label><span class="color_red ml5">*</span>重复密码：</label><input type="password" name="passwordtoo" id="passwordtoo" class="iput_t w200" /></li>
    </ul>
    </form>
	<div class="btm_btn mt50">
    	<dl>
        	<dd><input type="button" name="submit" id="updatePwdBtn" class="btn"  value="确&nbsp;定"  /></dd>
            <dd><input type="button" class="btn" onclick="javascript:history.go(-1)" value="取消" /></dd>
        </dl>
    </div>
      </div> 
    </div>
</body>
</html>
















